Securely executing smart contract operations in a trusted execution environment

ABSTRACT

Disclosed herein are methods, systems, and apparatus for securely executing smart contract operations in a trusted execution environment (TEE). One of the methods includes receiving, by a blockchain node participating in a blockchain network, a request to execute one or more software instructions in a service TEE hosted by the blockchain node, wherein the request is encrypted by a public key associated with the service TEE; decrypting the request with a first private key associated with the service TEE, wherein the first private key is paired with the public key; in response to decrypting the request, executing the one or more software instructions to produce an execution result; encrypting the execution result with a client encryption key associated with the service TEE to produce an encrypted result; and signing the encrypted result using a second private key associated with the TEE to produce a signed encrypted result.

CROSS-REFERENCE TO RELATED APPLICATIONS

This application is a continuation of PCT Application No.PCT/CN2019/084523, filed on Apr. 26, 2019, which is hereby incorporatedby reference in its entirety.

TECHNICAL FIELD

This specification relates to securely executing smart contractoperations in a trusted execution environment.

BACKGROUND

Distributed ledger systems (DLSs), which can also be referred to asconsensus networks, and/or blockchain networks, enable participatingentities to securely, and immutably store data. DLSs are commonlyreferred to as blockchain networks without referencing any particularuse case. An example of a type of blockchain network can includeconsortium blockchain networks provided for a select group of entities,which control the consensus process, and includes an access controllayer.

Smart contracts are programs that execute on blockchains. A smartcontract contains a set of pre-defined rules under which the parties tothat smart contract agree to interact with each other. If thepre-defined rules of the smart contract are met, the agreement definedin the smart contract is automatically enforced. A smart contract isusually tamper resistant and facilitates, verifies, and enforces thenegotiation or performance of an agreement or transaction.

In a consortium blockchain network, because only a selected group ofnodes control the consensus process, an attacker must gain control overa relatively small number of nodes in order to influence the consensusprocess. Although techniques have been proposed for addressing thesetypes of security issues in consortium blockchain networks, a moreeffective and secure solution would be advantageous.

SUMMARY

This specification describes technologies for securely executingrequested smart contract operations in a trusted execution environments(TEE) executed by a blockchain node. More particularly, embodiments ofthis specification enable the blockchain node to perform smart contractoperations in a secure and verifiable manner within a TEE such thatparties can trust that the environment in which the operations areexecuted has not been tampered with or compromised.

This specification also provides one or more non-transitorycomputer-readable storage media coupled to one or more processors andhaving instructions stored thereon which, when executed by the one ormore processors, cause the one or more processors to perform operationsin accordance with embodiments of the methods provided herein.

This specification further provides a system for implementing themethods provided herein. The system includes one or more processors, anda computer-readable storage medium coupled to the one or more processorshaving instructions stored thereon which, when executed by the one ormore processors, cause the one or more processors to perform operationsin accordance with embodiments of the methods provided herein.

It is appreciated that methods in accordance with this specification mayinclude any combination of the aspects and features described herein.That is, methods in accordance with this specification are not limitedto the combinations of aspects and features specifically describedherein, but also include any combination of the aspects and featuresprovided.

The details of one or more embodiments of this specification are setforth in the accompanying drawings and the description below. Otherfeatures and advantages of this specification will be apparent from thedescription and drawings, and from the claims.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 is a diagram illustrating an example of an environment that canbe used to execute embodiments of this specification.

FIG. 2 is a diagram illustrating an example of an architecture inaccordance with embodiments of this specification.

FIG. 3 is a diagram illustrating an example of a system in accordancewith embodiments of this specification.

FIG. 4 is a diagram illustrating an example of a system in accordancewith embodiments of this specification.

FIG. 5 depicts an example of a process that can be executed inaccordance with embodiments of this specification.

FIG. 6 depicts examples of modules of an apparatus in accordance withembodiments of this specification.

Like reference numbers and designations in the various drawings indicatelike elements.

DETAILED DESCRIPTION

This specification describes technologies for securely executingrequested smart contract operations in a trusted execution environments(TEE) executed by a blockchain node. More particularly, embodiments ofthis specification enable the blockchain node to perform smart contractoperations in a secure and verifiable manner within a TEE such thatparties can trust that the environment in which the operations areexecuted has not been tampered with or compromised.

To provide further context for embodiments of this specification, and asintroduced above, distributed ledger systems (DLSs), which can also bereferred to as consensus networks (e.g., made up of peer-to-peer nodes),and blockchain networks, enable participating entities to securely, andimmutably conduct transactions, and store data. Although the termblockchain is generally associated with particular networks, and/or usecases, blockchain is used herein to generally refer to a DLS withoutreference to any particular use case.

A blockchain is a data structure that stores transactions in a way thatthe transactions are immutable. Thus, transactions recorded on ablockchain are reliable and trustworthy. A blockchain includes one ormore blocks. Each block in the chain is linked to a previous blockimmediately before it in the chain by including a cryptographic hash ofthe previous block. Each block also includes a timestamp, its owncryptographic hash, and one or more transactions. The transactions,which have already been verified by the nodes of the blockchain network,are hashed and encoded into a Merkle tree. A Merkle tree is a datastructure in which data at the leaf nodes of the tree is hashed, and allhashes in each branch of the tree are concatenated at the root of thebranch. This process continues up the tree to the root of the entiretree, which stores a hash that is representative of all data in thetree. A hash purporting to be of a transaction stored in the tree can bequickly verified by determining whether it is consistent with thestructure of the tree.

Whereas a blockchain is a decentralized or at least partiallydecentralized data structure for storing transactions, a blockchainnetwork is a network of computing nodes that manage, update, andmaintain one or more blockchains by broadcasting, verifying andvalidating transactions, etc. As introduced above, a blockchain networkcan be provided as a public blockchain network, a private blockchainnetwork, or a consortium blockchain network. Embodiments of thisspecification are described in further detail herein with reference to aconsortium blockchain network. It is contemplated, however, thatembodiments of this specification can be realized in any appropriatetype of blockchain network.

In general, a consortium blockchain network is private among theparticipating entities. In a consortium blockchain network, theconsensus process is controlled by an authorized set of nodes, which canbe referred to as consensus nodes, one or more consensus nodes beingoperated by a respective entity (e.g., a financial institution,insurance company). For example, a consortium of ten (10) entities(e.g., financial institutions, insurance companies) can operate aconsortium blockchain network, each of which operates at least one nodein the consortium blockchain network.

In some examples, within a consortium blockchain network, a globalblockchain is provided as a blockchain that is replicated across allnodes. That is, all consensus nodes are in perfect state consensus withrespect to the global blockchain. To achieve consensus (e.g., agreementto the addition of a block to a blockchain), a consensus protocol isimplemented within the consortium blockchain network. For example, theconsortium blockchain network can implement a practical Byzantine faulttolerance (PBFT) consensus, described in further detail below.

FIG. 1 is a diagram illustrating an example of an environment 100 thatcan be used to execute embodiments of this specification. In someexamples, the example environment 100 enables entities to participate ina consortium blockchain network 102. The example environment 100includes computing devices 106, 108, and a network 110. In someexamples, the network 110 includes a local area network (LAN), wide areanetwork (WAN), the Internet, or a combination thereof, and connects websites, user devices (e.g., computing devices), and back-end systems. Insome examples, the network 110 can be accessed over a wired and/or awireless communications link.

In the depicted example, the computing systems 106, 108 can each includeany appropriate computing system that enables participation as a node inthe consortium blockchain network 102. Example computing devicesinclude, without limitation, a server, a desktop computer, a laptopcomputer, a tablet computing device, and a smartphone. In some examples,the computing systems 106, 108 hosts one or more computer-implementedservices for interacting with the consortium blockchain network 102. Forexample, the computing system 106 can host computer-implemented servicesof a first entity (e.g., user A), such as a transaction managementsystem that the first entity uses to manage its transactions with one ormore other entities (e.g., other users). The computing system 108 canhost computer-implemented services of a second entity (e.g., user B),such as a transaction management system that the second entity uses tomanage its transactions with one or more other entities (e.g., otherusers). In the example of FIG. 1, the consortium blockchain network 102is represented as a peer-to-peer network of nodes, and the computingsystems 106, 108 provide nodes of the first entity, and second entityrespectively, which participate in the consortium blockchain network102.

FIG. 2 depicts an example of a conceptual architecture 200 in accordancewith embodiments of this specification. The conceptual architecture 200includes an entity layer 202, a hosted services layer 204, and ablockchain network layer 206. In the depicted example, the entity layer202 includes three participants, Participant A, Participant B, andParticipant C, each participant having a respective transactionmanagement system 208.

In the depicted example, the hosted services layer 204 includesinterfaces 210 for each transaction management system 208. In someexamples, a respective transaction management system 208 communicateswith a respective interface 210 over a network (e.g., the network 110 ofFIG. 1) using a protocol (e.g., hypertext transfer protocol secure(HTTPS)). In some examples, each interface 210 provides communicationconnection between a respective transaction management system 208, andthe blockchain network layer 206. More particularly, the interface 210communicate with a blockchain network 212 of the blockchain networklayer 206. In some examples, communication between an interface 210, andthe blockchain network layer 206 is conducted using remote procedurecalls (RPCs). In some examples, the interfaces 210 “host” blockchainnetwork nodes for the respective transaction management systems 208. Forexample, the interfaces 210 provide the application programminginterface (API) for access to blockchain network 212.

As described herein, the blockchain network 212 is provided as apeer-to-peer network including a plurality of nodes 214 that immutablyrecord information in a blockchain 216. Although a single blockchain 216is schematically depicted, multiple copies of the blockchain 216 areprovided, and are maintained across the blockchain network 212. Forexample, each node 214 stores a copy of the blockchain. In someembodiments, the blockchain 216 stores information associated withtransactions that are performed between two or more entitiesparticipating in the consortium blockchain network.

A blockchain (e.g., the blockchain 216 of FIG. 2) is made up of a chainof blocks, each block storing data. Example data includes transactiondata representative of a transaction between two or more participants.While transactions are used herein by way of non-limiting example, it iscontemplated that any appropriate data can be stored in a blockchain(e.g., documents, images, videos, audio). Example transactions caninclude, without limitation, exchanges of something of value (e.g.,assets, products, services, currency). The transaction data is immutablystored within the blockchain. That is, the transaction data cannot bechanged.

Before storing in a block, the transaction data is hashed. Hashing is aprocess of transforming the transaction data (provided as string data)into a fixed-length hash value (also provided as string data). It is notpossible to un-hash the hash value to obtain the transaction data.Hashing ensures that even a slight change in the transaction dataresults in a completely different hash value. Further, and as notedabove, the hash value is of fixed length. That is, no matter the size ofthe transaction data the length of the hash value is fixed. Hashingincludes processing the transaction data through a hash function togenerate the hash value. An example of a hash function includes, withoutlimitation, the secure hash algorithm (SHA)-256, which outputs 256-bithash values.

Transaction data of multiple transactions are hashed and stored in ablock. For example, hash values of two transactions are provided, andare themselves hashed to provide another hash. This process is repeateduntil, for all transactions to be stored in a block, a single hash valueis provided. This hash value is referred to as a Merkle root hash, andis stored in a header of the block. A change in any of the transactionswill result in change in its hash value, and ultimately, a change in theMerkle root hash.

Blocks are added to the blockchain through a consensus protocol.Multiple nodes within the blockchain network participate in theconsensus protocol, and perform work to have a block added to theblockchain. Such nodes are referred to as consensus nodes. PBFT,introduced above, is used as a non-limiting example of a consensusprotocol. The consensus nodes execute the consensus protocol to addtransactions to the blockchain, and update the overall state of theblockchain network.

In further detail, the consensus node generates a block header, hashesall of the transactions in the block, and combines the hash value inpairs to generate further hash values until a single hash value isprovided for all transactions in the block (the Merkle root hash). Thishash is added to the block header. The consensus node also determinesthe hash value of the most recent block in the blockchain (i.e., thelast block added to the blockchain). The consensus node also adds anonce value, and a timestamp to the block header.

In general, PBFT provides a practical Byzantine state machinereplication that tolerates Byzantine faults (e.g., malfunctioning nodes,malicious nodes). This is achieved in PBFT by assuming that faults willoccur (e.g., assuming the existence of independent node failures, and/ormanipulated messages sent by consensus nodes). In PBFT, the consensusnodes are provided in a sequence that includes a primary consensus node,and backup consensus nodes. The primary consensus node is periodicallychanged. Transactions are added to the blockchain by consensus nodeswithin the blockchain network reaching an agreement as to the worldstate of the blockchain network. In this process, messages aretransmitted between consensus nodes, and each consensus nodes provesthat a message is received from a specified peer node, and verifies thatthe message was not modified during transmission.

In PBFT, the consensus protocol is provided in multiple phases with allconsensus nodes beginning in the same state. To begin, a client sends arequest to the primary consensus node to invoke a service operation(e.g., execute a transaction within the blockchain network). In responseto receiving the request, the primary consensus node multicasts therequest to the backup consensus nodes. The backup consensus nodesexecute the request, and each sends a reply to the client. The clientwaits until a threshold number of replies are received. In someexamples, the client waits for f+1 replies to be received, where f isthe maximum number of faulty consensus nodes that can be toleratedwithin the blockchain network. The final result is that a sufficientnumber of consensus nodes come to an agreement on the order of therecord that is to be added to the blockchain, and the record is eitheraccepted, or rejected.

In some blockchain networks, cryptography is implemented to maintainprivacy of transactions. For example, if two nodes want to keep atransaction private, such that other nodes in the blockchain networkcannot discern details of the transaction, the nodes can encrypt thetransaction data. Example cryptography includes, without limitation,symmetric encryption, and asymmetric encryption. Symmetric encryptionrefers to an encryption process that uses a single key for bothencryption (generating ciphertext from plaintext), and decryption(generating plaintext from ciphertext). In symmetric encryption, thesame key is available to multiple nodes, so each node can en-/de-crypttransaction data.

Asymmetric encryption uses keys pairs that each include a private key,and a public key, the private key being known only to a respective node,and the public key being known to any or all other nodes in theblockchain network. A node can use the public key of another node toencrypt data, and the encrypted data can be decrypted using other node'sprivate key. For example, and referring again to FIG. 2, Participant Acan use Participant B's public key to encrypt data, and send theencrypted data to Participant B. Participant B can use its private keyto decrypt the encrypted data (ciphertext) and extract the original data(plaintext). Messages encrypted with a node's public key can only bedecrypted using the node's private key.

Asymmetric encryption is used to provide digital signatures, whichenables participants in a transaction to confirm other participants inthe transaction, as well as the validity of the transaction. Forexample, a node can digitally sign a message, and another node canconfirm that the message was sent by the node based on the digitalsignature of Participant A. Digital signatures can also be used toensure that messages are not tampered with in transit. For example, andagain referencing FIG. 2, Participant A is to send a message toParticipant B. Participant A generates a hash of the message, and then,using its private key, encrypts the hash to provide a digital signatureas the encrypted hash. Participant A appends the digital signature tothe message, and sends the message with digital signature to ParticipantB. Participant B decrypts the digital signature using the public key ofParticipant A, and extracts the hash. Participant B hashes the messageand compares the hashes. If the hashes are same, Participant B canconfirm that the message was indeed from Participant A, and was nottampered with.

In some embodiments, nodes of the blockchain network, and/or nodes thatcommunicate with the blockchain network can operate using TEEs. At ahigh-level, a TEE is a trusted environment within hardware (one or moreprocessors, memory) that is isolated from the hardware's operatingenvironment (e.g., operating system (OS), basic input/output system(BIOS)). In further detail, a TEE is a separate, secure area of aprocessor that ensures the confidentiality, and integrity of codeexecuting, and data loaded within the main processor. Within aprocessor, the TEE runs in parallel with the OS. At least portions ofso-called trusted applications (TAs) execute within the TEE, and haveaccess to the processor and memory. Through the TEE, the TAs areprotected from other applications running in the main OS. Further, theTEE cryptographically isolates TAs from one another inside the TEE.

An example of a TEE includes Software Guard Extensions (SGX) provided byIntel Corporation of Santa Clara, Calif., United States. Although SGX isdiscussed herein by way of example, it is contemplated that embodimentsof this specification can be realized using any appropriate TEE.

SGX provides a hardware-based TEE. In SGX, the trusted hardware is thedie of the central processing until (CPU), and a portion of physicalmemory is isolated to protect select code and data. The isolatedportions of memory are referred to as enclaves. More particularly, anenclave is provided as an enclave page cache (EPC) in memory and ismapped to an application address space. The memory (e.g., DRAM) includesa preserved random memory (PRM) for SGX. The PRM is a continuous memoryspace in the lowest BIOS level and cannot be accessed by any software.Each EPC is a memory set (e.g., 4 KB) that is allocated by an OS to loadapplication data and code in the PRM. EPC metadata (EPCM) is the entryaddress for respective EPCs and ensures that each EPC can only be sharedby one enclave. That is, a single enclave can use multiple EPCs, whilean EPC is dedicated to a single enclave.

During execution of a TA, the processor operates in a so-called enclavemode when accessing data stored in an enclave. Operation in the enclavemode enforces an extra hardware check to each memory access. In SGX, aTA is compiled to a trusted portion, and an untrusted portion. Thetrusted portion is inaccessible by, for example, OS, BIOS, privilegedsystem code, virtual machine manager (VMM), system management mode(SMM), and the like. In operation, the TA runs and creates an enclavewithin the PRM of the memory. A trusted function executed by the trustedportion within the enclave is called by the untrusted portion, and codeexecuting within the enclave sees the data as plaintext data(unencrypted), and external access to the data is denied. The trustedportion provides an encrypted response to the call, and the TA continuesto execute.

An attestation process can be performed to verify that expected code(e.g., the trusted portion of the TA) is securely executing within theSGX-provided TEE. In general, the attestation process includes a TAreceiving an attestation request from a challenger (e.g., another nodein the blockchain network, a key management system (KMS) of theblockchain network). In response, the TA requests that its enclaveproduce a remote-attestation, also referred to as a quote. Producing theremote-attestation includes a local-attestation being sent from theenclave to a so-called quoting enclave, which verifies thelocal-attestation, and converts the local-attestation into theremote-attestation by signing the local-attestation using an asymmetricattestation key. The remote-attestation (quote) is provided to thechallenger (e.g., KMS of the blockchain network).

The challenger uses an attestation verification service to verify theremote-attestation. For SGX, Intel provides the Intel AttestationService (IAS), which receives the remote-attestation from thechallenger, and verifies the remote-attestation. More particularly, theIAS processes the remote-attestation, and provides a report (e.g.,attestation verification report (AVR)), which indicates whether theremote-attestation is verified. If not verified, an error can beindicated. If verified (the expected code is securely executing in theTEE), the challenger can start, or continue interactions with the TA.For example, in response to the verification, the KMS (as challenger)can issue asymmetric encryption keys (e.g., a public-key and private-keypair) to the node executing the TEE (e.g., through a key exchangeprocess, such as elliptical curve Diffie-Hellman (ECDH)) to enable thenode to securely communicate with other nodes, and/or clients.

In some blockchain networks, so-called smart contracts can be executed.Smart contracts can be described as digital representations ofreal-world, legal contracts having contractual terms affecting variousparties. A smart contract is implemented, stored, updated (as needed),and executed within, in the example context, a consortium blockchainnetwork. Contract parties associated with the smart contract (e.g.,buyers and sellers) are represented as nodes in the consortiumblockchain network. In some examples, the contract parties can includeentities (e.g., business enterprises) that are associated with the smartcontract (e.g., as parties to the smart contract).

In further detail, smart contracts are provided as computer-executableprograms that execute on blockchains (e.g., a node within a blockchainnetwork). A smart contract contains a set of pre-defined rules underwhich the parties to that smart contract agree to interact with eachother. If the pre-defined rules of the smart contract are met, theagreement defined in the smart contract is automatically enforced. Asmart contract is usually tamper resistant and facilitates, verifies,and enforces the negotiation or performance of an agreement ortransaction.

FIG. 3 is a diagram illustrating an example of a system 300 inaccordance with embodiments of this specification. As shown, system 300includes a blockchain network 302 including blockchain nodes 304 a-d.The blockchain nodes 304 a-d include service TEEs 306 a-d and keymanagement (KM) TEEs 308 a-d. The nodes 304 a-d have access to smartcontract service logic 330. A key management center 310 is communicablycoupled to the nodes 304 a-d.

Each of the nodes 304 a-d is blockchain node participating in theblockchain network 302 and contributing to the maintenance of ablockchain associated with the blockchain network 302 (not shown). Asdescribed above, the nodes 304 a-d can participate in a consensusprocess associated with the blockchain network 302, can collecttransactions into blocks for addition to the blockchain, can processtransactions requested by users of the blockchain network 302, canexecute operations encoded in smart contracts, and perform other tasksrelated to the management of the blockchain. In some embodiments, eachnode can be a computing device (e.g., a server) including one or moreprocessors, storage devices, and other components. In some cases, thenodes 304 a-d communicate over a communications network (not shown) toeach other and to other nodes participating in the blockchain network302. For the remainder of the description of FIG. 3, node 304 a will bedescribed as an example, with the understanding that nodes 304 b-d canalso include the features of node 304 a.

Node 304 a includes a service TEE 306 a. In some embodiments, theservice TEE 306 a is a secure application environment implemented usinga TEE technology (e.g., Intel SGX). One or more software programs orlibraries can be executed by the service TEE 306 a. For the purposes ofthe present specification, the service TEE 306 a refers to the secureenvironment (the TEE) as well as software executing inside the TEE thatperforms the described operations. In some embodiments, the service TEE306 a executes smart contract operations specified by encrypted clientrequests and outputs encrypted results associated with the smartcontract operations. This functionality is described in greater detailwith respect to FIG. 4 below.

Node 304 a also includes a key management TEE (KM TEE) 308 a. In someembodiments, the KM TEE 308 a is a secure application environmentimplemented using a TEE technology (e.g., Intel SGX). One or moresoftware programs or libraries can be executed by the KM TEE 308 a. Forthe purposes of the present specification, the KM TEE 308 a refers tothe secure environment (the TEE) as well as software executing insidethe TEE that performs the described operations. In some embodiments, theKM TEE 308 a obtains encryption keys from the key management center 310as described in greater detail with respect to FIG. 4 below.

The key management center 310 can generate, store, and maintainencryption keys. The key management center 310 can also authenticateidentities of KM TEEs 308 a-d and provide the encryption keys to thenodes 304 a-d through a remote attestation and key deployment process320. In some embodiments, the key management can further provideencryption keys to clients for interacting with the nodes 304 a-d. Thisfunctionality is described in greater detail with respect to FIG. 4below. In some embodiments, the key management center 310 can be one ormore servers or other computing devices in communication with one ormore nodes of the blockchain network 302 over a communications network(not shown). The key management center 310 can also include one or morestorage devices coupled to the key management center 310 or accessibleover the communications network for storing the encryption keys andother data.

In some cases, the key management center 310 operates to authenticatethe identities of the KM TEEs 308 a-d before performing encryption keydeployments. For example, prior to providing the one or more encryptionkeys (described below) to the KM TEE 308 a, the key management center310 can verify the authenticity of the KM TEE 308 a. This verificationensures that the software executed by the KM TEE 308 a has not beentampered with after being provisioned. In some embodiments, theverification can include a remote attestation process 320, such as thosedescribed above.

After the KM TEEs 308 a-d obtain the one or more encryption keys fromthe key management center 310, the keys can be forwarded to service TEEs306 a-d to perform cryptographic operations. In some cases, although aKM TEE and service TEE pair (e.g., KM TEE 308 a and service TEE 306 a)operate on a single node (e.g., node 304 a), they each have their ownindependent TEEs. As a result, information communicated between the KMTEEs 308 a-d and service TEEs 306 a-d is transmitted through untrustedarea. In such cases, the KM TEEs 308 a-d can authenticate the identitiesof the service TEEs 306 a-d, for example by performing a localattestation process.

Local attestation can allow an enclave to prove its identity orauthenticity to another enclave within the same local platform. Forexample, a KM TEE 308 a can send a challenge to verify the authenticityof the service TEE 306 a. Upon receiving the challenge, the service TEE306 a can request a hardware (e.g., CPU) of node 304 a to generate areport, which includes cryptographic proof that the service TEE 306 aexists on the node 304 a. The report can be provided to the KM TEE 308 ato verify that the enclave report was generated on the same platform bynode 304 a. In some cases, the local attestation can be performed basedon a symmetric key system where only the KM TEE 308 a verifying thereport and the enclave hardware generating the report know the symmetrickey, which is embedded in the hardware platform of node 304 a.

After the service TEE 306 a-d are authenticated through localattestations, the KM TEE 308 a-d can provide the one or more encryptionkeys to the service TEEs 306 a-d. In some cases, the KM TEE 308 a-d canprovide the encryption keys in response to the authentication of theservice TEE 306 a-d, or can provide the keys in response to one or morerequests by the service TEE 306 a-d.

The smart contract service logic 330 includes one or more smart contractdefinitions. Nodes 304 a-304 d execute particular operations from thesmart contract service logic 330 (e.g., upon request of a client, asshown in FIG. 4). In some embodiments, the smart contract definitions inthe smart contract service logic 330 include instructions to executed bynodes of the blockchain network 302. The smart contract service logic330 can include the smart contract definitions stored in one or moreblockchains maintained by the blockchain network 302 (not shown).

FIG. 4 is a diagram illustrating an example of a system 400 inaccordance with implementations of this specification. As shown, thesystem 400 includes the node 304 a (including the service TEE 306 a andthe KM TEE 308 a), and the key management center 310 described withrespect to FIG. 3. The system 400 also includes a client 480communicatively coupled to the key management center 310.

In operation, the system 400 can securely execute smart contractinstructions and produce encrypted results of the operation (e.g., forinclusion in a blockchain). As discussed above, the key managementcenter 310 can perform remote attestation to authenticate identity ofthe KM TEE 308 a before trusting it with the encryption keys. After theKM TEE 308 is authenticated, the key management center 310 can providean unseal private key 402, a root key 404 and a sign private key 406 tothe KM TEE 308 a of the Node 304 a. The key management center 310 alsohosts a seal public key 414 and a verification public key 416. The keymanagement center 310 provides these keys to authorized clients toperform encryption and decryption of various data associated with theservice TEE 306 a, as described below.

As shown, the key management center 310 provides the seal public key 414to the client 480. In some cases, the key management center 310authenticates the client 480 and only provides the seal public key 414if the client 480 is authorized to access it. The key management center310 can consult an internal or external permissions resource to makethis determination. The seal public key 414 is associated with an unsealprivate key 402 provided to the KM TEE 308 a. The seal public key 414and the unseal private key 402 form a key pair, meaning that dataencrypted with the seal public key 414 can be decrypted using the unsealprivate key 402.

The client 480 identifies a requested contract operation 450, which is asmart contract operation to be executed by an Ethereum virtual machine(VM) 460 deployed in the service TEE 306 a. In some cases, the smartcontract operations 450 include one or more instructions encoded in asmart contract programming language for execution by a VM operable toexecute instruction in that language. The smart contract operations 450can include an execution state for the smart contract associated withthe request contract operation 450. During execution of a smartcontract, multiple nodes of a blockchain network execute eachinstruction of the smart contract individually, and produce a resultindicating an execution state of the smart contract after the completionof the instruction. The execution state can include data associated withthe smart contract. Each executed instruction of the contract can changethe contents of the data (e.g., to store a value to be used by a laterinstruction in the smart contract). After execution of an instruction ofthe smart contract, the nodes of the blockchain network reach aconsensus on the new execution state after execution of the instruction.This consensus process is performed for each instruction executed in asmart contract, leading to a consensus as to the execution path of thesmart contract and, ultimately, as to the final result of the execution.

At 452, the client 480 encodes (or seals) the requested contractoperation 450 in a digital envelope 454 for transmission to the serviceTEE 306 a executed by the Node 304 a. For example, the client 480generates a temporary symmetric key 408 and encrypts the requestedcontract operation 450 using the key 408. The client 480 then encryptsthe temporary symmetric key 408 using the seal public key 414, andconcatenates the encrypted contract operation 450 and the encrypted key408 to produce the digital envelope 454.

The client 480 transmits the digital envelope 454 to the node 304 a,where it is provided to the service TEE 306 a. In some cases, the client480 can send the digital envelope 454 to multiple nodes 304 a-d torequest processing of the requested contract operation 450. In somecases, the client 480 can send digital envelopes created using sealpublic keys specific to the particular nodes. The client 480 can alsobroadcast the digital envelope 454 to the nodes 304 a-d in cases wherethe same seal public key 414 and unseal private key 402 are associatedwith all the nodes 304 a-d.

The service TEE 306 a receives the digital envelope 454 from the client480 and recovers the requested contract operation 450 from the digitalenvelope 454. As shown, the service TEE 306 a decodes the digitalenvelope 454 using the unseal private key 402 obtained from the KM TEE308 a. In some cases, the service TEE 306 a decrypts (unseals) thetemporary symmetric key 408 using the unseal private key 402 (at 456),and then decrypts the requested contract operation 450 using thetemporary symmetric key 408 (at 458).

The service TEE 306 a then executes the requested contract operation 450using a VM 460 deployed in the service TEE 306 a. In some embodiments,the VM 460 can be a VM configured to execute instructions of a smartcontract programming language, such as an Ethereum VM, or other type ofVM. In some cases, the VM 460 can access resources external the serviceTEE 306 a during execution of the operation 450, such as, for example,external servers, a blockchain, a database, or other resources indicatedby the operation 450. In some embodiments, accessing external resourcescan be restricted or denied, such that the entirety of the execution ofthe operation depends only on data stored in the service TEE 306 a (suchas the smart contract state). This type of restriction can furtherreduce the possibility of tampering with the execution of the operation450.

The execution of the operation 450 by the VM 460 can produce one or moreresults. In some cases, the results can include an execution state ofthe smart contract after executing the operation 450, as describedabove. At 462, the result of the smart contract operation 450 isencrypted by the service TEE 306 a using a contract key 412. Thecontract key 412 is derived (at 410) from a root key 404 based on a keyderivation function (KDF). In some examples, the KDF can be performedbased on iterative hash algorithms, such as HMAC-basedextract-and-expand key derivation function (HKDF) or pseudo-randomfunction (PRF). The contract key can be provided by the KM TEE 308 a tothe service TEE 306 a. In some embodiments, the root key 404 can be asymmetric encryption key associated with the node 304 a. The root key404 can also include one or more subkeys that can be derived from theroot key 404. The contract key 412 can be one of these subkeys. In somecases, the root key 404 itself can be used to encrypt the result at 462.

After encrypting the result, the service TEE 308 a, at 464, signs theencrypted result using a sign private key 406 provided by the KM TEE 308a to the service TEE 306 a, so as to produce a signed result 466. Thiscan allow later verification of the signed result by a third party (forexample, a client), using the verification public key 416(correspondingly paired to the sign private key 406) maintained by thekey management center 310. In some cases, signing the encrypted resultby the sign private key 406 can include encrypting the encrypted resulttogether with the contract key 412 used to encrypt the result. In such acase, a third party holding the verification public key 416 can decryptthe the contract key 412 first, and further use the contract key 412 todecrypt the result.

In some cases, the service TEE 306 a can store the signed result 466 ina blockchain. As described above, a third party holding the verificationpublic key 416 can use the key to decrypt the result 466 in order toinspect. For example, the client 480 can retrieve the verificationpublic key 416 from the key management center 310 (e.g., subject toauthentication as previously described), and can access and decrypt thesigned result 466 using the verification public key 416. The client 480can then request that the next operation in the smart contract beexecuted by the service TEE 306 a, an can include the requested nextoperation and the execution state of the smart contract (from thedecrypted signed result 466) in the digital envelope sent to the serviceTEE 306 a.

FIG. 5 depicts an example of a process that can be executed inaccordance with embodiments of this specification. At 502, a blockchainnode (e.g., 304 a) participating in a blockchain network (e.g., 302)receives a request to execute one or more software instructions in aservice TEE hosted by the blockchain node, wherein the request isencrypted by a public key associated with the service TEE.

At 504, the blockchain node decrypts the request with a first privatekey associated with the service TEE, wherein the first private key ispaired with the public key.

At 506, the blockchain node executes the one or more softwareinstructions to produce an execution result.

At 508, the blockchain node encrypts the execution result with a clientencryption key associated with the service TEE to produce an encryptedresult.

At 510, the blockchain node signs the encrypted result using a secondprivate key associated with the TEE to produce a signed encryptedresult.

In some cases, the public key is a first public key, and the clientencryption key is one of a second public key or a symmetric key derivedfrom a root key based on a key derivation function.

In some cases, the blockchain node further hosts a key management TEEthat stores one or more of the first private key, the second privatekey, and the key management TEE provides the first private key, thesecond private key, and the root key to the service TEE after anidentity of the service TEE is authenticated based on performing a localattestation initiated by the key management TEE.

In some cases, the first private key, the second private key, and theroot key are generated by a key management center and are provided tothe key management TEE after an identity of the key management TEE isauthenticated based on performing a remote attestation initiated by thekey management center.

In some cases, the first private key and the root key are provided bythe key management TEE to the service TEE in response to a rebootingoperation of the service TEE.

In some cases, the one or more software instructions are associated witha smart contract, and the root key is selected from a plurality of theroot keys stored in the key management TEE based on a state of the smartcontract.

In some cases, the first public key is generated by the key managementcenter and provided to a client for encrypting the request.

In some cases, the request received by the blockchain node furtherincludes using the client encryption key to encrypts the one or moresoftware instructions.

In some cases, decrypting the request with the first private key furthercomprises: decrypting the client encryption key with the first privatekey; and decrypting the one or more software instructions with theclient encryption key.

FIG. 6 depicts examples of modules of an apparatus 600 in accordancewith embodiments of this specification. The apparatus 600 can be anexample embodiment of a blockchain node executing within a blockchainnetwork. The apparatus 600 can correspond to the embodiments describedabove, and the apparatus 600 includes the following: a receiving module602 that receives a request to execute one or more software instructionsin a service TEE hosted by the blockchain node, wherein the request isencrypted by a public key associated with the service TEE; a decryptingmodule 604 that decrypts the request with a first private key associatedwith the service TEE, wherein the first private key is paired with thepublic key; an executing module 606 that executes the one or moresoftware instructions to produce an execution result; an encryptingmodule 608 that encrypts the execution result with a client encryptionkey associated with the service TEE to produce an encrypted result; asigning module 610 that signs the encrypted result using a secondprivate key associated with the TEE to produce a signed encryptedresult.

The system, apparatus, module, or unit illustrated in the previousembodiments can be implemented by using a computer chip or an entity, orcan be implemented by using a product having a certain function. Atypical embodiment device is a computer, and the computer can be apersonal computer, a laptop computer, a cellular phone, a camera phone,a smartphone, a personal digital assistant, a media player, a navigationdevice, an email receiving and sending device, a game console, a tabletcomputer, a wearable device, or any combination of these devices.

For an embodiment process of functions and roles of each module in theapparatus, references can be made to an embodiment process ofcorresponding steps in the previous method. Details are omitted here forsimplicity.

Because an apparatus embodiment basically corresponds to a methodembodiment, for related parts, references can be made to relateddescriptions in the method embodiment. The previously describedapparatus embodiment is merely an example. The modules described asseparate parts may or may not be physically separate, and partsdisplayed as modules may or may not be physical modules, may be locatedin one position, or may be distributed on a number of network modules.Some or all of the modules can be selected based on actual demands toachieve the objectives of the solutions of the specification. A personof ordinary skill in the art can understand and implement theembodiments of the present application without creative efforts.

Referring again to FIG. 6, it can be interpreted as illustrating aninternal functional module and a structure of a blockchain nodeexecuting within a blockchain network and functioning as an executionbody. An execution body in essence can be an electronic device, and theelectronic device includes the following: one or more processors; and amemory configured to store an executable instruction of the one or moreprocessors.

The techniques described in this specification produce one or moretechnical effects. For example, the described techniques enables partiesto a consortium blockchain network to verify that blockchain nodes inthe network that are responsible for executing smart contract operationsand arriving at a consensus as to the results of those operations havenot been compromised by an attacker. This verification has the effect ofreducing the preventing or reducing the likelihood of an attacker takingcontrol of one or more of the blockchain nodes and successfullytampering with the execution of the smart contract operations or theconsensus process, leading a more secure embodiment of a consortiumblockchain network that is more resistant to attacks.

Described embodiments of the subject matter can include one or morefeatures, alone or in combination. One embodiment includes acomputer-implemented method comprising the actions of receiving, by ablockchain node participating in a blockchain network, a request toexecute one or more software instructions in a service TEE hosted by theblockchain node, wherein the request is encrypted by a public keyassociated with the service TEE; decrypting, by the blockchain node inin the service TEE, the request with a first private key associated withthe service TEE, wherein the first private key is paired with the publickey; in response to decrypting the request, executing, by the blockchainnode in the service TEE, the one or more software instructions toproduce an execution result; encrypting, by the blockchain node in theservice TEE, the execution result with a client encryption keyassociated with the service TEE to produce an encrypted result; andsigning, by the blockchain node in the TEE, the encrypted result using asecond private key associated with the TEE to produce a signed encryptedresult.

The foregoing and other described embodiments can each, optionally,include one or more of the following features:

A first feature, combinable with any of the following features,specifies that the public key is a first public key, and the clientencryption key is one of a second public key or a symmetric key derivedfrom a root key based on a key derivation function.

A second feature, combinable with any of the previous or followingfeatures, specifies that the blockchain node further hosts a keymanagement TEE that stores one or more of the first private key, thesecond private key, and wherein the key management TEE provides thefirst private key, the second private key, and the root key to theservice TEE after an identity of the service TEE is authenticated basedon performing a local attestation initiated by the key management TEE.

A third feature, combinable with any of the previous or followingfeatures, specifies that the first private key, the second private key,and the root key are generated by a key management center and areprovided to the key management TEE after an identity of the keymanagement TEE is authenticated based on performing a remote attestationinitiated by the key management center.

A fourth feature, combinable with any of the previous or followingfeatures, specifies that the first private key and the root key areprovided by the key management TEE to the service TEE in response to arebooting operation of the service TEE.

A fifth feature, combinable with any of the previous or followingfeatures, specifies that the one or more software instructions areassociated with a smart contract, and wherein the root key is selectedfrom a plurality of the root keys stored in the key management TEE basedon a state of the smart contract.

A sixth feature, combinable with any of the previous or followingfeatures, specifies that the first public key is generated by the keymanagement center and provided to a client for encrypting the request.

A seventh feature, combinable with any of the previous or followingfeatures, specifies that the request received by the blockchain nodefurther includes using the client encryption key to encrypts the one ormore software instructions.

An eighth feature, combinable with any of the previous or followingfeatures, specifies that decrypting the request with the first privatekey further comprises: decrypting the client encryption key with thefirst private key; and decrypting the one or more software instructionswith the client encryption key.

A ninth feature, combinable with any of the previous or followingfeatures, specifies that key management center stores a verificationpublic key that corresponds to the second private key and provides theverification public key to the client for verifying the signed encryptedresult.

Embodiments of the subject matter and the actions and operationsdescribed in this specification can be implemented in digital electroniccircuitry, in tangibly-embodied computer software or firmware, incomputer hardware, including the structures disclosed in thisspecification and their structural equivalents, or in combinations ofone or more of them. Embodiments of the subject matter described in thisspecification can be implemented as one or more computer programs, e.g.,one or more modules of computer program instructions, encoded on acomputer program carrier, for execution by, or to control the operationof, data processing apparatus. For example, a computer program carriercan include one or more computer-readable storage media that haveinstructions encoded or stored thereon. The carrier may be a tangiblenon-transitory computer-readable medium, such as a magnetic, magnetooptical, or optical disk, a solid state drive, a random access memory(RAM), a read-only memory (ROM), or other types of media. Alternatively,or in addition, the carrier may be an artificially generated propagatedsignal, e.g., a machine-generated electrical, optical, orelectromagnetic signal that is generated to encode information fortransmission to suitable receiver apparatus for execution by a dataprocessing apparatus. The computer storage medium can be or be part of amachine-readable storage device, a machine-readable storage substrate, arandom or serial access memory device, or a combination of one or moreof them. A computer storage medium is not a propagated signal.

A computer program, which may also be referred to or described as aprogram, software, a software application, an app, a module, a softwaremodule, an engine, a script, or code, can be written in any form ofprogramming language, including compiled or interpreted languages, ordeclarative or procedural languages; and it can be deployed in any form,including as a stand-alone program or as a module, component, engine,subroutine, or other unit suitable for executing in a computingenvironment, which environment may include one or more computersinterconnected by a data communication network in one or more locations.

A computer program may, but need not, correspond to a file in a filesystem. A computer program can be stored in a portion of a file thatholds other programs or data, e.g., one or more scripts stored in amarkup language document, in a single file dedicated to the program inquestion, or in multiple coordinated files, e.g., files that store oneor more modules, sub programs, or portions of code.

Processors for execution of a computer program include, by way ofexample, both general- and special-purpose microprocessors, and any oneor more processors of any kind of digital computer. Generally, aprocessor will receive the instructions of the computer program forexecution as well as data from a non-transitory computer-readable mediumcoupled to the processor.

The term “data processing apparatus” encompasses all kinds ofapparatuses, devices, and machines for processing data, including by wayof example a programmable processor, a computer, or multiple processorsor computers. Data processing apparatus can include special-purposelogic circuitry, e.g., an FPGA (field programmable gate array), an ASIC(application specific integrated circuit), or a GPU (graphics processingunit). The apparatus can also include, in addition to hardware, codethat creates an execution environment for computer programs, e.g., codethat constitutes processor firmware, a protocol stack, a databasemanagement system, an operating system, or a combination of one or moreof them.

The processes and logic flows described in this specification can beperformed by one or more computers or processors executing one or morecomputer programs to perform operations by operating on input data andgenerating output. The processes and logic flows can also be performedby special-purpose logic circuitry, e.g., an FPGA, an ASIC, or a GPU, orby a combination of special-purpose logic circuitry and one or moreprogrammed computers.

Computers suitable for the execution of a computer program can be basedon general or special-purpose microprocessors or both, or any other kindof central processing unit. Generally, a central processing unit willreceive instructions and data from a read only memory or a random accessmemory or both. Elements of a computer can include a central processingunit for executing instructions and one or more memory devices forstoring instructions and data. The central processing unit and thememory can be supplemented by, or incorporated in, special-purpose logiccircuitry.

Generally, a computer will also include, or be operatively coupled toreceive data from or transfer data to one or more storage devices. Thestorage devices can be, for example, magnetic, magneto optical, oroptical disks, solid state drives, or any other type of non-transitory,computer-readable media. However, a computer need not have such devices.Thus, a computer may be coupled to one or more storage devices, such as,one or more memories, that are local and/or remote. For example, acomputer can include one or more local memories that are integralcomponents of the computer, or the computer can be coupled to one ormore remote memories that are in a cloud network. Moreover, a computercan be embedded in another device, e.g., a mobile telephone, a personaldigital assistant (PDA), a mobile audio or video player, a game console,a Global Positioning System (GPS) receiver, or a portable storagedevice, e.g., a universal serial bus (USB) flash drive, to name just afew.

Components can be “coupled to” each other by being commutatively such aselectrically or optically connected to one another, either directly orvia one or more intermediate components. Components can also be “coupledto” each other if one of the components is integrated into the other.For example, a storage component that is integrated into a processor(e.g., an L2 cache component) is “coupled to” the processor.

To provide for interaction with a user, embodiments of the subjectmatter described in this specification can be implemented on, orconfigured to communicate with, a computer having a display device,e.g., a LCD (liquid crystal display) monitor, for displaying informationto the user, and an input device by which the user can provide input tothe computer, e.g., a keyboard and a pointing device, e.g., a mouse, atrackball or touchpad. Other kinds of devices can be used to provide forinteraction with a user as well; for example, feedback provided to theuser can be any form of sensory feedback, e.g., visual feedback,auditory feedback, or tactile feedback; and input from the user can bereceived in any form, including acoustic, speech, or tactile input. Inaddition, a computer can interact with a user by sending documents toand receiving documents from a device that is used by the user; forexample, by sending web pages to a web browser on a user's device inresponse to requests received from the web browser, or by interactingwith an app running on a user device, e.g., a smartphone or electronictablet. Also, a computer can interact with a user by sending textmessages or other forms of message to a personal device, e.g., asmartphone that is running a messaging application, and receivingresponsive messages from the user in return.

This specification uses the term “configured to” in connection withsystems, apparatus, and computer program components. For a system of oneor more computers to be configured to perform particular operations oractions means that the system has installed on it software, firmware,hardware, or a combination of them that in operation cause the system toperform the operations or actions. For one or more computer programs tobe configured to perform particular operations or actions means that theone or more programs include instructions that, when executed by dataprocessing apparatus, cause the apparatus to perform the operations oractions. For special-purpose logic circuitry to be configured to performparticular operations or actions means that the circuitry has electroniclogic that performs the operations or actions.

While this specification contains many specific embodiment details,these should not be construed as limitations on the scope of what isbeing claimed, which is defined by the claims themselves, but rather asdescriptions of features that may be specific to particular embodiments.Certain features that are described in this specification in the contextof separate embodiments can also be realized in combination in a singleembodiment. Conversely, various features that are described in thecontext of a single embodiments can also be realized in multipleembodiments separately or in any suitable subcombination. Moreover,although features may be described above as acting in certaincombinations and even initially be claimed as such, one or more featuresfrom a claimed combination can in some cases be excised from thecombination, and the claim may be directed to a subcombination orvariation of a subcombination.

Similarly, while operations are depicted in the drawings and recited inthe claims in a particular order, this should not be understood asrequiring that such operations be performed in the particular ordershown or in sequential order, or that all illustrated operations beperformed, to achieve desirable results. In certain circumstances,multitasking and parallel processing may be advantageous. Moreover, theseparation of various system modules and components in the embodimentsdescribed above should not be understood as requiring such separation inall embodiments, and it should be understood that the described programcomponents and systems can generally be integrated together in a singlesoftware product or packaged into multiple software products.

Particular embodiments of the subject matter have been described. Otherembodiments are within the scope of the following claims. For example,the actions recited in the claims can be performed in a different orderand still achieve desirable results. As one example, the processesdepicted in the accompanying figures do not necessarily require theparticular order shown, or sequential order, to achieve desirableresults. In some cases, multitasking and parallel processing may beadvantageous.

1. A computer-implemented method for securely executing smart contractoperations in a trusted execution environment (TEE), the methodcomprising: receiving, by a blockchain node participating in ablockchain network, a request to execute one or more softwareinstructions associated with a smart contract in a service TEE hosted bythe blockchain node, wherein the request is encrypted by a public keyassociated with the service TEE; decrypting, by the blockchain node inin the service TEE, the request with a first private key associated withthe service TEE, wherein the first private key is paired with the publickey; in response to decrypting the request, executing, by the blockchainnode in the service TEE, the one or more software instructions toproduce an execution result; encrypting, by the blockchain node in theservice TEE, the execution result with a client encryption keyassociated with the service TEE to produce an encrypted result; andsigning, by the blockchain node in the TEE, the encrypted result using asecond private key associated with the TEE to produce a signed encryptedresult.
 2. The computer-implemented method of claim 1, wherein thepublic key is a first public key, and the client encryption key is oneof a second public key or a symmetric key derived from a root key basedon a key derivation function.
 3. The computer-implemented method ofclaim 2, wherein the blockchain node further hosts a key management TEEthat stores one or more of the first private key, the second privatekey, and wherein the key management TEE provides the first private key,the second private key, and the root key to the service TEE after anidentity of the service TEE is authenticated based on performing a localattestation initiated by the key management TEE.
 4. Thecomputer-implemented method of claim 3, wherein the first private key,the second private key, and the root key are generated by a keymanagement center and are provided to the key management TEE after anidentity of the key management TEE is authenticated based on performinga remote attestation initiated by the key management center.
 5. Thecomputer-implemented method of claim 3, wherein the first private keyand the root key are provided by the key management TEE to the serviceTEE in response to a rebooting operation of the service TEE.
 6. Thecomputer-implemented method of claim 3, wherein the root key is selectedfrom a plurality of root keys stored in the key management TEE based ona state of the smart contract.
 7. The computer-implemented method ofclaim 4, wherein the first public key is generated by the key managementcenter and provided to a client for encrypting the request.
 8. Thecomputer-implemented method of claim 1, wherein the request received bythe blockchain node further includes using the client encryption key toencrypts the one or more software instructions.
 9. Thecomputer-implemented method of claim 8, wherein decrypting the requestwith the first private key further comprises: decrypting the clientencryption key with the first private key; and decrypting the one ormore software instructions with the client encryption key.
 10. Thecomputer-implemented method of claim 4, wherein the key managementcenter stores a verification public key that corresponds to the secondprivate key and provides the verification public key to a client forverifying the signed encrypted result.
 11. A non-transitory,computer-readable storage medium storing one or more instructionsexecutable by a computer system to perform operations for securelyexecuting smart contract operations in a trusted execution environment(TEE), the operations comprising: receiving, by a blockchain nodeparticipating in a blockchain network, a request to execute one or moresoftware instructions associated with a smart contract in a service TEEhosted by the blockchain node, wherein the request is encrypted by apublic key associated with the service TEE; decrypting, by theblockchain node in in the service TEE, the request with a first privatekey associated with the service TEE, wherein the first private key ispaired with the public key; in response to decrypting the request,executing, by the blockchain node in the service TEE, the one or moresoftware instructions to produce an execution result; encrypting, by theblockchain node in the service TEE, the execution result with a clientencryption key associated with the service TEE to produce an encryptedresult; and signing, by the blockchain node in the TEE, the encryptedresult using a second private key associated with the TEE to produce asigned encrypted result.
 12. The non-transitory, computer-readablestorage medium of claim 11, wherein the public key is a first publickey, and the client encryption key is one of a second public key or asymmetric key derived from a root key based on a key derivationfunction.
 13. The non-transitory, computer-readable storage medium ofclaim 12, wherein the blockchain node further hosts a key management TEEthat stores one or more of the first private key, the second privatekey, and wherein the key management TEE provides the first private key,the second private key, and the root key to the service TEE after anidentity of the service TEE is authenticated based on performing a localattestation initiated by the key management TEE.
 14. The non-transitory,computer-readable storage medium of claim 13, wherein the first privatekey, the second private key, and the root key are generated by a keymanagement center and are provided to the key management TEE after anidentity of the key management TEE is authenticated based on performinga remote attestation initiated by the key management center.
 15. Thenon-transitory, computer-readable storage medium of claim 13, whereinthe first private key and the root key are provided by the keymanagement TEE to the service TEE in response to a rebooting operationof the service TEE.
 16. The non-transitory, computer-readable storagemedium of claim 13, wherein the root key is selected from a plurality ofroot keys stored in the key management TEE based on a state of the smartcontract.
 17. The non-transitory, computer-readable storage medium ofclaim 14, wherein the first public key is generated by the keymanagement center and provided to a client for encrypting the request.18. The non-transitory, computer-readable storage medium of claim 11,wherein the request received by the blockchain node further includesusing the client encryption key to encrypts the one or more softwareinstructions.
 19. The non-transitory, computer-readable storage mediumof claim 18, wherein decrypting the request with the first private keyfurther comprises: decrypting the client encryption key with the firstprivate key; and decrypting the one or more software instructions withthe client encryption key.
 20. The non-transitory, computer-readablestorage medium of claim 14, wherein the key management center stores averification public key that corresponds to the second private key andprovides the verification public key to a client for verifying thesigned encrypted result.
 21. A computer-implemented system, comprising:one or more computers; and one or more computer memory devicesinteroperably coupled with the one or more computers and havingtangible, non-transitory, machine-readable media storing one or moreinstructions that, when executed by the one or more computers, performone or more operations for securely executing smart contract operationsin a trusted execution environment (TEE), the operations comprising:receiving, by a blockchain node participating in a blockchain network, arequest to execute one or more software instructions associated with asmart contract in a service TEE hosted by the blockchain node, whereinthe request is encrypted by a public key associated with the serviceTEE, decrypting, by the blockchain node in in the service TEE, therequest with a first private key associated with the service TEE,wherein the first private key is paired with the public key, in responseto decrypting the request, executing, by the blockchain node in theservice TEE, the one or more software instructions to produce anexecution result, encrypting, by the blockchain node in the service TEE,the execution result with a client encryption key associated with theservice TEE to produce an encrypted result, and signing, by theblockchain node in the TEE, the encrypted result using a second privatekey associated with the TEE to produce a signed encrypted result. 22.The computer-implemented system of claim 21, wherein the public key is afirst public key, and the client encryption key is one of a secondpublic key or a symmetric key derived from a root key based on a keyderivation function.
 23. The computer-implemented system of claim 22,wherein the blockchain node further hosts a key management TEE thatstores one or more of the first private key, the second private key, andwherein the key management TEE provides the first private key, thesecond private key, and the root key to the service TEE after anidentity of the service TEE is authenticated based on performing a localattestation initiated by the key management TEE.
 24. Thecomputer-implemented system of claim 23, wherein the first private key,the second private key, and the root key are generated by a keymanagement center and are provided to the key management TEE after anidentity of the key management TEE is authenticated based on performinga remote attestation initiated by the key management center.
 25. Thecomputer-implemented system of claim 23, wherein the first private keyand the root key are provided by the key management TEE to the serviceTEE in response to a rebooting operation of the service TEE.
 26. Thecomputer-implemented system of claim 23, wherein the root key isselected from a plurality of root keys stored in the key management TEEbased on a state of the smart contract.
 27. The computer-implementedsystem of claim 24, wherein the first public key is generated by the keymanagement center and provided to a client for encrypting the request.28. The computer-implemented system of claim 21, wherein the requestreceived by the blockchain node further includes using the clientencryption key to encrypts the one or more software instructions. 29.The computer-implemented system of claim 28, wherein decrypting therequest with the first private key further comprises: decrypting theclient encryption key with the first private key; and decrypting the oneor more software instructions with the client encryption key.
 30. Thecomputer-implemented system of claim 24, wherein the key managementcenter stores a verification public key that corresponds to the secondprivate key and provides the verification public key to a client forverifying the signed encrypted result.